package short_semester.questionnaire_planet.response.AnalyseController;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import short_semester.questionnaire_planet.pojo.QuestionnaireRecord;

import java.util.Collection;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class RecordResponse {
    String title;
    String description;
    
    @JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    Date date;
    Long completeTime;
    String ip;
    String province;
    String city;
    Collection<QuestionRecordAnalyseResponse> questions;
    
    String type;
    Boolean isAutoLabel;
    Integer grade;
    Integer rank;
    Integer count;
    
    public RecordResponse(QuestionnaireRecord record){
        title = record.getQuestionnaire().getTitle();
        type = record.getQuestionnaire().getType();
        description = record.getQuestionnaire().getDescription();
        
        date = record.getSubmitDate();
        completeTime = record.getConsTime();
        ip = record.getIp();
        province = record.getProvince();
        city = record.getCity();
        grade = record.getGrade();
        
        isAutoLabel = record.getQuestionnaire().getIsAutoLabel();
    }
}
